package com.example.springboot.Jms;



import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Destination;
import javax.jms.Queue;
import javax.jms.Topic;


@Component
public class JMSProducer {
    
    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private Queue queue;

    @Autowired
    private Topic topic;

    /**
     * 点对点模式生产消息
     * @param message
     */
    public void sendQueueMessage(String message) {
        System.out.println("生产消息："+message);
      jmsMessagingTemplate.convertAndSend(this.queue,message);
    }

    /**
     * 发布、订阅模式生产消息
     * @param message
     */
    public void sendTopicMessage(String message){
        System.out.println("Topic生产消息："+message);
        jmsMessagingTemplate.convertAndSend(this.topic,message);
    }
}